/// <reference path="disco.ontology.d.ts" />

export class Context extends Default.Container {
    constructor(serviceUri: string) {
        var config = {
            name: 'oData',
            oDataServiceHost: serviceUri,
            maxDataServiceVersion: '3.0',
            // HINT: The following line is not working yet.
            // TODO: As a Developer I want to specify custom request headers so that I can set the odata metadata options and other headers.
            Accept: 'application/json;odata=nometadata'
        };
        super(config);
    }
}
$data.EntityContext.prototype['authData'] = () => AuthData();
export var AuthData = () => ({ user: "anonymous", password: "" });

$data.EntityContext.prototype['prepareRequest'] = function(r) {
		var __encodeBase64 = $data['Authentication'].BasicAuth.BasicAuth.prototype.__encodeBase64;
		if(this.context.authData) {
			var auth = this.context.authData();
			if(auth.user != null)
				r[0].headers['Authorization'] = "Basic  " + __encodeBase64(auth.user + ':' + auth.password);
		}
};